package stringTest;

public class StringDemo {
    public static void main(String[] args) {
        String s1="123abc";
        String s2="123abc";
        System.out.println(s1==s2);
        //true
        String s3="123abc";
        String s4=new String("123abc");
        System.out.println(s4==s1);//false
        //new 则是创建一个新的对象，不推荐

        s1=s1+"!";
        System.out.println(s1==s2);

        String s5="123"+"abc";//预编译
        System.out.println(s5==s2);//true
        String s="123";
        String s6=s+"abc";
        System.out.println(s6==s2);//false
        String s7="123abc";
        String s8=new String("123abc");
        System.out.println(s7==s8);//false
        System.out.println(s7.equals(s8));//true

    }
}
